package com.thread;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ApplicationThreadPool {

    public static ThreadPoolExecutor hreadPoolExecutor = new ThreadPoolExecutor(
            2, // 核心线程数
            4, // 最大线程数
            60, // 生存时间
            TimeUnit.SECONDS, // 生存时间单位
            new ArrayBlockingQueue<>(4), // 任务队列
            Executors.defaultThreadFactory(), // 线程工厂
            new ThreadPoolExecutor.CallerRunsPolicy() // 拒绝策略是给主线程处理
    );

}
